package com.nblog.controller.admin;

import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.jfinal.kit.PathKit;
import com.nblog.annotation.ControllerBind;
import com.nblog.auth.annotation.RequiresPermissions;
import com.nblog.constant.Constant;
import com.nblog.interceptor.admin.LoginInterceptor;
import com.nblog.interceptor.admin.SysLogInterceptor;
import com.nblog.model.SysUser;
import com.nblog.plugin.ioc.annotation.JFAutowired;
import com.nblog.service.SysResService;
import com.nblog.service.SysUserService;
@Before({LoginInterceptor.class,SysLogInterceptor.class})
@ControllerBind(controllerKey="/admin")
public class IndexController extends Controller {
	@JFAutowired
	SysUserService sysUserService;
	@JFAutowired
	SysResService sysResService;
	@RequiresPermissions(value={"/admin/index"})
	public void index(){
		String ctx=this.getRequest().getContextPath();
		System.out.println("ctx:"+ctx);
		SysUser sysUser=getAttr(Constant.SYSUSER);
		String menu=sysResService.getSysUserMenuView(ctx,sysUser.getId(),"/admin/res");
		setAttr("menu", menu);
		System.out.println(menu);
		render("index.html");
	}
	public void home(){
		render("home.html");
	}
}
